package cn.tedu.csmall.product.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

public class IdUtils {

    private static DateTimeFormatter dateTimeFormatter
            = DateTimeFormatter.ofPattern("yyMMddHHmmssSSS");

    private static Random random = new Random();

    public static Long getId() {
        LocalDateTime now = LocalDateTime.now();
        String dateTimeString = dateTimeFormatter.format(now);
        int randomNumber = random.nextInt(8999)+1000;
        String result = dateTimeString+randomNumber;
        long id =Long.valueOf(result);
        return id;

    }

}
